package main

import (
	"goweb/pkg/get"

	"github.com/gin-gonic/gin"
	_ "github.com/lib/pq"
)

// 跨域
func Middle() gin.HandlerFunc {
	return func(c *gin.Context) {
		c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
		c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
		c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With, Token, Language, From")
		c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS, GET, PUT")
		if c.Request.Method == "OPTIONS" {
			c.AbortWithStatus(204)
			return
		} else {
			c.Next()
		}
	}
}

func main() {

	r := gin.Default()

	r.Use(Middle())
	get.Gettestuser(r)
	get.Getaccount(r)
	get.Register_account(r)
	get.Gettestlog(r)
	get.Inertlog(r)
	get.Getstudent(r)
	get.Updatestudent(r)
	get.Updatetestlog(r)
	get.Getmbtiintj(r)
	get.Getmbtiintp(r)
	get.Getmbtientj(r)
	get.Getmbtientp(r)
	get.Getmbtiinfj(r)
	get.Getmbtiinfp(r)
	get.Getmbtienfj(r)
	get.Getmbtienfp(r)
	get.Getmbtiistj(r)
	get.Getmbtiisfj(r)
	get.Getmbtiestj(r)
	get.Getmbtiesfj(r)
	get.Getmbtiistp(r)
	get.Getmbtiisfp(r)
	get.Getmbtiestp(r)
	get.Getmbtiesfp(r)
	get.Getper1(r)
	get.Getper2(r)
	get.Getper3(r)
	get.Getper4(r)
	get.Getper5(r)
	get.Getper6(r)
	get.Getper7(r)
	get.Getper8(r)
	get.Getper9(r)
	get.Getper10(r)
	get.Getper11(r)
	get.Getper12(r)
	get.Getper13(r)
	get.Getper14(r)
	get.Getper15(r)
	get.Getper16(r)
	r.Run(":8887")
}
